package com.example.farmer.Adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.farmer.Fragment.Circle.FollowFragment;
import com.example.farmer.Fragment.Circle.LatestFragment;
import com.example.farmer.Fragment.CircleFragment;

import java.util.List;

public class TabsPagerAdapter extends FragmentStateAdapter {

    private List<String> followList;
    private List<String> latestList;
    public TabsPagerAdapter(@NonNull CircleFragment fm) {
        super(fm);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        switch (position) {
            case 0:
                return  LatestFragment.newInstance(latestList); // 最新页

            case 1:
                return FollowFragment.newInstance(followList); // 关注页
            default:
                return new Fragment();
        }
    }

    @Override
    public int getItemCount() {
        return 2; // 只有两个页面
    }
    public void setLatestList(List<String> latestList) {
        this.latestList = latestList;
    }

    public void setFollowList(List<String> followList) {
        this.followList = followList;
    }


}